import org.springframework.util.StringUtils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class mll {

    public static void main(String[] args) {
        try {
            File file = new File("f:city.txt");
            BufferedReader br = new BufferedReader(new FileReader(file));//构造一个BufferedReader类来读取文件
            String s = null;
            int i = 1;
            Map<String, List<City>> cityMap = new HashMap<>(26);
            String sSS = "0ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            while ((s = br.readLine()) != null) {//使用readLine方法，一次读一行
                //System.out.println(s);
                cc city = (cc) JsonUtil.getObj(s, cc.class);
                //System.out.println("insert into city(ID,SPELL,NAME,LETTER) VALUES(" + i + ",'" + city.getPinyin() + "','" + city.getName() + "','" + city.getLetter() + "');");
                //System.out.println("insert into city(SPELL,NAME,letter_id) VALUES('" + city.getPinyin() + "','" + city.getName() + "',"+sSS.indexOf(city.getLetter())+");");
                if (!cityMap.containsKey(city.getLetter())) {
                    cityMap.put(city.getLetter(),new ArrayList<>());
                }
                cityMap.get(city.getLetter()).add(new City(i,city.getPinyin(), city.getName()));
                i++;
            }
            System.out.println(JsonUtil.getJSON(cityMap));
            br.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
